/**
 * 实名认证
 */
define(function (require, exports, module) {


    var UI = require("js/UI"),
        uiTip=require("ui/tip");
    var $homeCnt = $("#home .cnt");
    var reg_phone = /^[1][358][0-9]{9}$/;
    var $userForm = $homeCnt.find(".userForm");


    var $form1=$userForm.eq(0),$form2=$userForm.eq(1);

    $homeCnt.find(".bindTit a").unbind("click.name").bind("click.name", function () {
        $form1.find(".number").val("")
        $form1.fadeIn();
        return false
    })



    $form1.find("button[type=submit]").unbind("click.sub").bind("click.sub", function () {
        var $phone=$form1.find(".phone"),$number=$form1.find(".number");
        var _phone=$.trim($phone.val()), _number=$.trim($number.val());
        if(!_phone){
            //UI.tooltip("error", "请输入已绑定手机");
            uiTip($phone, "请输入已绑定手机", "right").show();
            $phone.focus();
            return false
        }else{
            if(!_phone.match(reg_phone)){
                //UI.tooltip("error", "请输入正确格式的手机号");
                uiTip($phone, "请输入正确格式的手机号", "right").show();
                $phone.focus();
                return false
            }
        }

        if(!_number){
            //UI.tooltip("error", "请输入验证码");
            uiTip($number, "请输入验证码", "right").show();
            $number.focus();
            return false
        }else{
            //验证
        }
        $form2.find("input").val("");
        $form2.fadeIn();
        return false

    })

    $userForm.find(".ipt1 a").unbind("click.number").bind("click.number", function () {
        var $this=$(this),$phone=$this.closest(".userForm").find(".phone"),_phone=$.trim($phone.val())
        if(!_phone){
            //UI.tooltip("error", "请输入手机号码");
            uiTip($phone, "请输入手机号码", "right").show();
            $phone.focus();
            return false
        }else{
            if(!_phone.match(reg_phone)){
               // UI.tooltip("error", "请输入正确格式的手机号");
                uiTip($phone, "请输入正确格式的手机号", "right").show();
                $phone.focus();
                return false
            }
        }
        UI.ajax("","get",{phone:_phone}, function (flag,json) {
            
        })
    })


    $form2.find("button[type=submit]").unbind("click.sub").bind("click.sub", function () {
        var $phone=$form2.find(".phone"),$number=$form2.find(".number");
        var _phone=$.trim($phone.val()), _number=$.trim($number.val());
        if(!_phone){
            //UI.tooltip("error", "请输入新手机号");
            uiTip($phone, "请输入新手机号", "right").show();
            $phone.focus();
            return false
        }else{
            if(!_phone.match(reg_phone)){
                //UI.tooltip("error", "请输入正确格式的手机号");
                uiTip($phone, "请输入正确格式的手机号", "right").show();
                $phone.focus();
                return false
            }
        }

        if(!_number){
            //UI.tooltip("error", "请输入验证码");
            uiTip($number, "请输入验证码", "right").show();
            $number.focus();
            return false
        }else{
            //验证
        }
    })

})